/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.quangtin3.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Quang
 */
@Entity
@Table(name = "column_type")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ColumnType.findAll", query = "SELECT c FROM ColumnType c"),
    @NamedQuery(name = "ColumnType.findById", query = "SELECT c FROM ColumnType c WHERE c.id = :id"),
    @NamedQuery(name = "ColumnType.findByName", query = "SELECT c FROM ColumnType c WHERE c.name = :name"),
    @NamedQuery(name = "ColumnType.findByDescription", query = "SELECT c FROM ColumnType c WHERE c.description = :description"),
    @NamedQuery(name = "ColumnType.findByDataListSupported", query = "SELECT c FROM ColumnType c WHERE c.dataListSupported = :dataListSupported")})
public class ColumnType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Size(max = 64)
    @Column(name = "NAME")
    private String name;
    @Size(max = 256)
    @Column(name = "DESCRIPTION")
    private String description;
    @Column(name = "DATA_LIST_SUPPORTED")
    private Boolean dataListSupported;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "columnType")
    private List<CollectionColumn> collectionColumnList;

    public ColumnType() {
    }

    public ColumnType(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Boolean getDataListSupported() {
        return dataListSupported;
    }

    public void setDataListSupported(Boolean dataListSupported) {
        this.dataListSupported = dataListSupported;
    }

    @XmlTransient
    public List<CollectionColumn> getCollectionColumnList() {
        return collectionColumnList;
    }

    public void setCollectionColumnList(List<CollectionColumn> collectionColumnList) {
        this.collectionColumnList = collectionColumnList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ColumnType)) {
            return false;
        }
        ColumnType other = (ColumnType) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.quangtin3.entity.ColumnType[ id=" + id + " ]";
    }
    
}
